<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>资讯列表·思通投研·让数据驱动投资价值!</title>
	<link href="${pageContext.request.contextPath }/img/webLogoIcon.png" rel="shortcut icon">
    <link href="${pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/font-awesome.css" rel="stylesheet">

    <link href="${pageContext.request.contextPath }/css/animate.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/style.css" rel="stylesheet">
    

	<link href="${pageContext.request.contextPath }/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <!-- FooTable -->
    <link href="${pageContext.request.contextPath }/css/footable.core.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/datepicker3.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/mypage.css" rel="stylesheet">
    <style>
		.select2_demo_1{
			float: left;
			width: 120px;
			display: inline;
			margin-left: 10px;
		}
		.form-control{
			display: inline;
		}
		
		.col-sm-3{
			float:right;
			width: 560px;
		}
		.input-group{
			float:right;
			width: 240px;
			margin-left: 5px;
		}
	   td{
	        vertical-align:middle;
	    }
	    .select::after{
	    	content: '';
	    	display: block;
	    	clear: both;
	    }
	    .select{
	    	width: 100%;
	    	min-height: 20px;
	    	padding: 10px;
	    	background: #fff;
	    }
	    .select select{
	    	display: inline-block;
	    	float: left;
	    	margin-right: 20px;
    	    width: 120px;
	    }
	    .select button {
		float: left;
		}
		.select-text{
			background-color: #FFFFFF;
		    background-image: none;
		    border: 1px solid #e5e6e7;
		    border-radius: 1px;
		    color: inherit;
		    display: block;
		    padding: 6px 12px;
		    font-size: 14px;
		}
	</style>

</head>

<body>

    <div id="wrapper">

        <nav class="navbar-default navbar-static-side" role="navigation">
            <%request.setAttribute("LEFT", "messagelist");%>
			<%@include file="left-factory.jsp"%>
        </nav>

        <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom">
         <jsp:include page="head-factory.jsp" flush="true" /> 
        </div>
        <div class="row wrapper border-bottom white-bg page-heading">
            <div class="col-lg-9">
                <h2>资讯列表</h2>
                <ol class="breadcrumb">
                	<li class="nav-main1">
                		<a href="${pageContext.request.contextPath}/admin/tosystem_overview">主页</a>
                	</li>
                	<li class="nav-main2" >
                			<a id="navigation1" href="#" >客户端</a>
                	</li>
                	<li class="active">
                		<a >资讯列表页</a>
                	</li>
                </ol>
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="col-lg-12">
                    <div class="ibox float-e-margins">
                    <div class="select">
                    	<select class="form-control" id="time" onchange="timeseek()">
                    	<option value="1" ${time == 1? 'selected':'' }>24小时</option>
                    	<option value="2" ${time == 2? 'selected':'' }>7天</option>
                    	<option value="3" ${time == 3? 'selected':'' }>30天</option>
                    	</select>
                    	<select class="form-control" id="websiz" onchange="seek()">
                    	<option value="" selected="selected">全部平台</option>
                    	<c:forEach items="${entiy}" var="my">
	                    	<option value="${my.name}">${my.name}</option>
                    	</c:forEach>
                    	</select>
                    </div>
                        <div class="ibox-content">
<!--                         	<div class="btn btn-primary pull-left">以下是昨日未采集到数据的种子信息</div> -->

                
                        	
                        	
            
                
               
	            
	            <table class="footable table table-stripped toggle-arrow-tiny" data-page-size="25"><!-- data-page-size="25" -->
                                <thead>
                                <tr>
                                   
                                    <th style="width: 15%;">标题</th>
                                    <th style="width: 10%;">作者</th>
                                    <th style="width: 10%;">来源平台</th>
                                    <th style="width: 10%;">时间</th>
                                    
                                </tr>
                                </thead>
                                <tbody id = "tbody">
                                <c:forEach items="${arr}" var="arr">
                              	<tr>
	                              		
	                              		<td><a onclick="help('${arr.source_url}')">${arr.title}</a></td>
	                              		<td>${arr.author}</td>
	                              		<td>${arr.sourcewebsitename}</td>
	                              		<td>${arr.publish_time}</td>
                              	</tr>
                              	</c:forEach>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="7">

											<div class="box" id="box" style="float: right;"></div>

									
                                    </td>
                                </tr>
                                </tfoot>
                            </table>

                        </div>
                    </div>
                </div>
        </div>
        </div>
<jsp:include page="footer.jsp" flush="true" />
        </div>
        </div>


    <!-- Mainly scripts -->
    <script src="${pageContext.request.contextPath }/js/jquery-2.1.1.js"></script>
    <script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.metisMenu.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.slimscroll.min.js"></script>

    <!-- Custom and plugin javascript -->
    <script src="${pageContext.request.contextPath }/js/inspinia.js"></script>
    <script src="${pageContext.request.contextPath }/js/pace.min.js"></script>
    


    <!-- FooTable -->
    <script src="${pageContext.request.contextPath }/js/footable.all.min.js"></script>
    <script src="${pageContext.request.contextPath}/js/mypage.js"></script>
    
    <script src="${pageContext.request.contextPath }/js/plugins/toastr/toastr.min.js"></script>
	<!-- Sweet alert -->
	<script src="${pageContext.request.contextPath }/js/plugins/sweetalert/sweetalert.min.js"></script>
	
    <!-- Page-Level Scripts -->
    <script>
    $(document).ready(function() {
        $('.footable').footable();
    });
    $(function(){
    	let pageCount = '${page_count}';
    	if(pageCount>500){
    		pageCount = 500
    	}
		paging('${count}',pageCount,'${page}');
	});
    
    function help(url){
    	window.open(url);
    }
   	function seek(pageNo){
   		
   		var name = $('#websiz option:selected').val();
   		var day = $('#time option:selected').val();
   		$.ajax({
			type : 'post',
			url : "${basePath}/spider-factory/message/webplatform",
			data : {
				name:name,
				day:day,
				pageNo:pageNo},
			dateType:"json",
			success:function(res){
				console.log(res)
				 groupList(res);
			},
			error:function(err){
				console.log(err)
			}
			
		});
   	}
   	
   	function timeseek(pageNo){
   		var name = $('#websiz option:selected').val();
   		var day = $('#time option:selected').val();
   		$.ajax({
			type : 'post',
			url : "${basePath}/spider-factory/message/webplatform",
			data : {
				name:name,
				day:day,
				pageNo:pageNo},
			dateType:"json",
			success:function(res){
				
				 groupList(res);
			},
			error:function(err){
				console.log(err)
			}
			
		});
   	}
   	
   	
   // 组装数据列表
   function groupList(res) {
	   let listStr1 = '';
	   let arrObj = res.arr;
	   let pageCount = res.pageCount;
	   let pageNum = res.pageNum;
	   let totalCount = res.totalCount;
	   if(pageCount>500){
		   pageCount = 500;
		}
	   if(pageCount==0||pageCount=="0"){
		   pageCount = 1
	   }
	   paging(totalCount,pageCount, pageNum)
	   for(let i=0;i<arrObj.length;i++){
		   let obj = arrObj[i];
		   console.log(obj)
		   let article_public_id = obj.article_public_id;
		   let author = obj.author;
		   let publish_time = obj.publish_time;
		   let source_url = obj.source_url;
		   let sourcewebsitename = obj.sourcewebsitename;
		   let title = obj.title;
		   let str0 = '<tr><td><a href="'+source_url+'" target="view_window">'+title+'</a></td><td>'+author+'</td><td>'+sourcewebsitename+'</td><td>'+publish_time+'</td></tr>'
			listStr1 += str0;
	   }
	   $("#tbody").html(listStr1);
}
   		
		function paging(totalData,totalPage, pagenum) {
			$('#box').paging({
				initPageNo : pagenum, // 初始页码
				totalPages : totalPage, //总页数
				totalCount : '合计' + totalData + '条数据', // 条目总数
				slideSpeed : 600, // 缓动速度 单位毫秒
				jump : true, //是否支持跳转
				callback : function(page) {
					// 回调函数
				}
			});
		}
		function search(){
			JumpToPage(1);
		}

		function JumpToPage(pagenum) {
			if(pagenum>500){
				pagenum = 500;
			}
			seek(pagenum);
		}
		
		function seedDetail(id){
			window.open('${pageContext.request.contextPath}/getseeddetail?seedid='+id)
		}
		

		
		//跑马灯方法 
// 		 function init(){
// 			    //获取标题
// 			    var title=document.title;
// 			    //分割字符串--->字符数组
// 			    var arr=title.split("");
// 			    //删除第一个元素并返回该元素
// 			    var e=arr.shift();
// 			    //把一个对象添加到数组末尾
// 			    arr.push(e);
// 			    //把数组转换成字符串
// 			    var marquee=arr.join("");
// 			    //返回给浏览器
// 			    document.title=marquee;
// 			    //定时一直执行
// 			    window.setTimeout("init()",1000);
// 			}
// 			window.onload=init;
		 
		
    </script>

    <!-- FooTable -->


</body>

</html>
